class Solution {
public:
    vector<int> twoSum(vector<int>& nums, int target) {
        int n=nums.size();
        vector<int> res(2);
        unordered_map<int,int> map;
        for(int i=0;i<n;i++){
            int t=target-nums[i];
            if(map.count(t)){
                    res={i,map[t]};
                    break;
            }
            map[nums[i]]=i;
    }
    return res;
    }
};